package com.io.example.demoparent.dto;

import lombok.*;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"username"})
@Builder
public class UserDto {

    private String username;

    private int age;

    private double score;

    @Singular("addHobby")
    private List<String> hobby;



    @SneakyThrows
    public void  shitHappens()
    {
        Thread.sleep(100);
    }

    @Synchronized
    public void concurrency(){
        System.out.println("Synchronized修饰代码方法开始执行");
    }

    //自动关闭资源
    @SneakyThrows
    public void copyFile(String in,String out){
        @Cleanup FileInputStream fileInputStream = new FileInputStream(in);
        @Cleanup FileOutputStream fileOutputStream = new FileOutputStream(out);
    }



    public static void main( String[] args )
    {

       UserDto user= UserDto.builder().username("xxxx").age(10).score(100).addHobby("xxx").addHobby("xxx").build();
        System.out.println("user = " + user);
    }
}
